const { Controller } = require('egg');


class articleController extends Controller {
  // 获取文章详情
  async page() {
    const { ctx } = this;
    const info = ctx.request.query;
    await ctx.service.article.getPage(info,ctx);
  }
  // 添加文章
  async add() {
    const { ctx } = this;
    const info = ctx.request.body;
    const file = ctx.request.files[0];
    await ctx.service.article.add(info,file,ctx);
  }
  // 删除文章
  async delete() {
    const { ctx } = this;
    const info = ctx.request.body;
    await ctx.service.article.delete(info,ctx);
  }
  // 获取文章评论详情
  async comPage() {
    const { ctx } = this;
    const info = ctx.request.query;
    await ctx.service.article.getComPage(info,ctx);
  }
  // 添加评论
  async addCom() {
    const { ctx } = this;
    const info = ctx.request.body;
    await ctx.service.article.addComPage(info,ctx);
  }
  // 删除评论
  async deleteCom() {
    const { ctx } = this;
    const info = ctx.request.body;
    await ctx.service.article.deleteCom(info,ctx);
  }
}

module.exports = articleController;